package edu.tamu.cs.studio;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class ReversiActivity extends Activity implements OnClickListener{
	int requestCode;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
        setContentView(R.layout.main);
        
        Button buttonBlack = (Button) findViewById(R.id.button_black);
        buttonBlack.setOnClickListener(this);
        
        Button buttonWhite = (Button) findViewById(R.id.button_white);
        buttonWhite.setOnClickListener(this);
        
        Button buttonPlay = (Button) findViewById(R.id.button_play);
        buttonPlay.setOnClickListener(this);
        
        Button buttonHighscore = (Button) findViewById(R.id.button_highscore);
        buttonHighscore.setOnClickListener(this);
    }
    
	public void onClick(View v) {
		SharedPreferences gameSettings = getSharedPreferences("gameSettings", MODE_WORLD_READABLE);
		SharedPreferences.Editor editor = gameSettings.edit();
		editor.clear();
		// TODO Auto-generated method stub
		switch(v.getId()) {
		case R.id.button_black:
			//We will invoke an Intent when this happens
			
	        editor.putInt("choosenColor", 1);
	        editor.commit();
			break;
		case R.id.button_white:
			//We will invoke a different Intent when this happens
			
	        editor.putInt("choosenColor", 2);
	        editor.commit();
			
			break;
		case R.id.button_play:
			//This will start a new game and switch the app to the larry's gamescreen view
			
			Intent intent = new Intent(this, Tempgamescreen.class);	//tempgamescreen is a temporary place holder
			startActivityForResult(intent, requestCode);
    		break;
    		
		case R.id.button_highscore:
			//This will show the high score view that Abhay has made
			
			Intent intent2 = new Intent(this, Lab3Activity.class);	//temphighscreen is a temporary place holder
			startActivityForResult(intent2, requestCode);
    		break;
		}
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	    if(resultCode==2){
	        finish();
	    }
	}
}